import QtQuick
import QtQuick.Controls
import Qt.labs.platform as Platform

ApplicationWindow {
    function openFileDialog() { fileOpenDialog.open(); }
    function openAboutDialog() { aboutDialog.open(); }

    visible: true
    title: qsTr("Image Viewer")

    background: Rectangle {
        color: 'darkgray'
    }

    Image {
        id: image
        anchors.fill: parent
        fillMode: Image.PreserveAspectFit
        asynchronous: true
    }

    Platform.FileDialog {
        id: fileOpenDialog
        title: "Choose a picture"
        nameFilters: [
            "Image files(*.png *jpg)", "All files(*.*)"
        ]
        onAccepted: image.source = fileOpenDialog.file
    }
    Dialog {
        id: aboutDialog
        width: 300; height: 150
        anchors.centerIn: parent
        title: "About"
        Label {
            anchors.fill: parent
            text: "0123456789ABCEFGHIJKLMNOPQRSTUVWXYZ"
            horizontalAlignment: Text.AlignHCenter
        }
        standardButtons: Platform.StandardButton.Ok
    }
}
